package com.tensquare.article.dao;

import com.tensquare.article.pojo.Article;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;

/**
 * & ProjectName：  tensquare-parent
 * & PackageName:   com.tensquare.article.dao
 * & Creation_Date： 2020/3/31 01:56
 * & Author：しの
 * ----------------------------------
 * & Description:
 */
public interface ArticleDao extends JpaRepository<Article,String>,JpaSpecificationExecutor<Article> {
    //注意：如果使用的是增、删、改sql语句，则需要添加@Modifying注解

    //1 文章审核
    @Modifying
    @Query(nativeQuery = true,
            value ="update tb_article set state='1' where id=?1" )
    void examine(String articleId);
    //2 文章点赞
    @Modifying
    @Query(nativeQuery = true,
            value = "update tb_article set thumbup=thumbup+1 where id =?1")
    void thumbup(String articleId);
}
